package cn.edu.sdjzu.xg.eagle.Service;

import cn.edu.sdjzu.xg.eagle.dao.TeacherDaoImpl;
import cn.edu.sdjzu.xg.eagle.entity.Condition;
import cn.edu.sdjzu.xg.eagle.entity.Pagination;
import cn.edu.sdjzu.xg.eagle.entity.Teacher;
import cn.edu.sdjzu.xg.eagle.util.JdbcHelper;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;

public class TeacherService {

    public static Collection<Teacher> findTeachersWithCondition(Pagination pagination, List<Condition> conditionList)
            throws SQLException {
        Connection connection = JdbcHelper.getConn();

        try {
            return TeacherDaoImpl.getInstance().findTeachersWithCondition(conditionList, connection);
        } finally {
            JdbcHelper.close(connection);
        }
    }

    public static Collection<Teacher>findTeachersWithPagination(Pagination pagination, List<Condition> conditionList)throws SQLException {
        Connection connection = JdbcHelper.getConn();
        try{
            return TeacherDaoImpl.getInstance().findTeachersWithPagination(conditionList, pagination, connection);
        }finally{
            JdbcHelper.close(connection);
        }
    }
}
